package eu.ahsx.limboa.utils
{
	
	/***
	 * 	ObjectUtils
	 * 	
	 * 	@author Masy Alexandre
	 * */
	public class ObjectUtils
	{
		
		/**
		 * 	Retrieve the number of property stored in an object.
		 * 	The object will be enumarated to count the number of item in it.
		 * 
		 * 	@param o Object	The object to count
		 * 	@return uint The number of item in it.
		 * */
		public static function getLength(o:Object):uint
		{
			var len:uint = 0;
			for (var item:* in o)
				if (item != "mx_internal_uid")
					len++;
			return len;
		}
		
		/**
		 * 	Retrieve the first element in the object.
		 * 
		 * 	@param o Object
		 * 	@param del Boolean If true, the value will be deleted from the object, will be acting just like the shift method.  Else not. 
		 * */
		public static function getFirst(o:Object, del:Boolean = false):*
		{
			var ret:*;
			
			for (var item:* in o)
				if (item != "mx_internal_uid")
				{
					ret = o[item];
					if (del)
						delete o[item]
					break;
				}
			
			return ret;
		}
		
	}
}